package zth.com.kotlindemo.presenter

import android.support.v4.app.Fragment
import zth.com.kotlindemo.R
import zth.com.kotlindemo.data.MenuData
import zth.com.kotlindemo.fragment.MovieFragment
import zth.com.kotlindemo.fragment.NewsFragment
import zth.com.kotlindemo.fragment.TextFragment
import zth.com.kotlindemo.fragment.WeatherFragment
import zth.com.kotlindemo.view.MainView

/**
 * Created by Sun.Star on 2017/5/18.
 */
class MainPresenter {
    private var mainView : MainView?=null

    constructor(mainView: MainView?) {
        this.mainView = mainView
        mainView!!.initView()
    }

    fun initMain(menutList : MutableList<MenuData>,fragmentList : MutableList<Fragment>){
        var mainFragment = MovieFragment()
        var newsFragment = NewsFragment()
        var textFragment = TextFragment()
        var weatherFragment = WeatherFragment()
        fragmentList!!.add(mainFragment)
        fragmentList!!.add(newsFragment)
        fragmentList!!.add(textFragment)
        fragmentList!!.add(weatherFragment)
        var menuData = MenuData("电影", R.mipmap.movie)
        var menuData1 = MenuData("新闻",R.mipmap.news)
        var menuData2 = MenuData("文章",R.mipmap.text)
        var menuData3 = MenuData("天气",R.mipmap.weather1)
        menutList!!.add(menuData)
        menutList!!.add(menuData1)
        menutList!!.add(menuData2)
        menutList!!.add(menuData3)
        mainView!!.loadFragment()
        mainView!!.loadMenu()
    }

    fun changePage(page:Int){
        mainView!!.changePage(page)
    }

}